/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dados;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Cripto {
    
    private String msg;
    
    public Cripto(String msg) {
        this.msg = msg;
    }
    
    public String encrypt ()  {
        
        MessageDigest m = null;
        String hash = null;

        try{
            m = MessageDigest.getInstance("MD5");
        }
        catch(NoSuchAlgorithmException e) {}        
        
        m.reset();
        m.update(msg.getBytes());
        byte[] digest = m.digest();
        
        
        BigInteger bint = new BigInteger(1,digest);
        hash = bint.toString(16);                                
        
        
        while(hash.length() < 32)
            hash = "0" + hash;
        
        return hash;
    }
    
    
    
}
